// ignore_for_file: constant_identifier_names, depend_on_referenced_packages

import 'package:dio/dio.dart';

import '../common/config.dart';
class DioUtil {

  /// 连接超时时间
  static const int CONNECT_TIMEOUT = 60 * 1000;

  /// 响应超时时间
  static const int RECEIVE_TIMEOUT = 60 * 1000;

  static DioUtil? _instance;
  static Dio _dio = Dio();

  Dio get dio => _dio;

  DioUtil._internal() {
    _instance = this;
    _instance?._init();
  }

  factory DioUtil() => _instance ?? DioUtil._internal();

  static DioUtil getInstance() {
    _instance ?? DioUtil._internal();
    return _instance!;
  }

  _init() {
    /// 初始化基本选项
    BaseOptions options = BaseOptions(
        baseUrl: AppInfo()['base_home'],
        connectTimeout: CONNECT_TIMEOUT,
        receiveTimeout: RECEIVE_TIMEOUT);
    /// 初始化dio
    _dio = Dio(options);
  }
}